import request from '/@/utils/request'

const apiText = 'customer'

// 查
export function getCustomerListApi(params: any) {
  return request({
    url: `/api/${apiText}/list`,
    method: 'get',
    params,
  })
}

// 下拉
export function getCustomerAllApi() {
  return request({
    url: `/api/${apiText}/all`,
    method: 'get',
  })
}

// 详情
export function getCustomerDetailsApi(id: any) {
  return request({
    url: `/api/${apiText}/info/${id}`,
    method: 'get',
  })
}

// 增
export function addCustomerListApi(data: any) {
  return request({
    url: `/api/${apiText}/create`,
    method: 'post',
    data,
  })
}

// 改
export function editCustomerListApi(data: any) {
  return request({
    url: `/api/${apiText}/update/${data.id}`,
    method: 'put',
    data,
  })
}

// 删
export function delCustomerListApi(id: any) {
  return request({
    url: `/api/${apiText}/delete/${id}`,
    method: 'delete',
  })
}

// 客户合同
export function getCustomerContractsApi(params: any) {
  return request({
    url: `/api/${apiText}/contracts`,
    method: 'get',
    params,
  })
}

// 销售额排行榜
export function getCustomerSalesRankingApi(params: any) {
  return request({
    url: `/api/${apiText}/sales_ranking`,
    method: 'get',
    params,
  })
}
